<head th:include="certificateWeb/headFoot :: headerCss"></head>
<link href="/css/certificateWeb/login.css" rel="stylesheet">
<div th:include="certificateWeb/headFoot :: header"></div>
<style type="text/css">
    .login-panel {
        margin: auto;
        width: 85%;
        box-shadow: 0 0 5px #e70012;
        padding: 20px 0 0;
    }

    .btn_login {
        border: 1px solid #e70012;
        background-color: #e70012;
        color: #fff;
        border-radius: 2px;
        width: 270px;
    }

</style>
<body class="signin">
<div style="width: 100%;margin:30% auto">
    <!--<h1 style="text-align: center;font-size: 42px"><a style="color: #fff" href="/certificate/homepage">湖南金职伟业证书信息平台</a></h1>-->
    <div class="row">
        <div class="login-panel">
            <div class="div-1">
                <h3 class="title">用户登录</h3>
                <div class="box_1">
                    <label class="label">&nbsp;用户名：</label>&nbsp;&nbsp;
                    <label class="label"><input style="color: #555555 ;" type="text" name="username" id="name"
                                                class="form-control reg_web" placeholder="用户名"/></label>
                </div>
                <div class="box_1">
                    <label class="label">&nbsp;密&nbsp;&nbsp;&nbsp;&nbsp;码：</label>&nbsp;&nbsp;
                    <label class="label"><input style="color: #555555 ;" type="password" name="password"
                                                    id="password"
                                                class="form-control reg_web" placeholder="密码"/></label><br/>
                </div>
                <div class="reg">
                    <label class="label"><a style="color:#666; margin-left:16px"
                                                href="/certificate/forgetPass">忘记密码</a></label>
                    <label class="label"><a style="color:#e70012; margin-right: 15px"
                                                href="/certificate/registerWeb">立即注册</a></label>
                    <label class="label"><a style="color:#e70012; margin-right: 15px"
                                                th:href="${url}">扫一扫登录</a></label>
                </div>
                <button class="btn btn_login" style="margin: 10px auto 30px 45px" onClick="login();">登录</button>
            </div>
        </div>
    </div>
</div>
<!--<div th:include="certificateWeb/headFoot :: footer"></div>-->
<script src="/lib/jquery/jquery.min.js"></script>
<script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
<script src="/lib/jquery/jquery.min.js"></script>
<script type="text/javascript">
    function login() {
        var username = $("#name").val();
        var password = $("#password").val();
        if ('' == username) {
            layer.msg('请输入用户名');
            return false
        }
        if ('' == password) {
            layer.msg('请输入密码');
            return false
        }
        var s = "";
        for (var i = 0; i < password.length; i++) {
            s += String.fromCharCode(password.charAt(i).charCodeAt() ^ 't'.charCodeAt());
        }
        $.ajax({
            type: "POST",
            url: "/certificate/sendLogin",
            data: {username: username, password: s},
            success: function (r) {
                // console.log("rrrr = " , r );
                // console.log("document.referrer",document.referrer)
                if (r.code == 0) {

                    window.localStorage.setItem("userName", r.data.userName);
                    window.localStorage.setItem("token", r.data.token);
                    window.localStorage.setItem("unreadNum0", r.data.unreadNum0);
                    window.localStorage.setItem("unreadNum1", r.data.unreadNum1);
                    location.href = '/certificate/dataDownload/teachingMobile'
                    // if (r.data.type != 1) {
                    //     if (document.referrer != '') {
                    //         if (document.referrer.indexOf('forgetPass') != -1 || document.referrer.indexOf('registerWeb') != -1) {
                    //             location.href = '/certificate/aboutMobile'
                    //         } else {
                    //             location.href = document.referrer
                    //         }
                    //     } else {
                    //         location.href = '/certificate/aboutMobile'
                    //     }
                    // } else {
                    //     if (r.data.uName == null) {
                    //         location.href = '/certificate/aboutMobile'
                    //         // layer.confirm('系统检测到您为机构会员，请前往个人中心完善个人和机构信息', {
                    //         //     closeBtn: 0,
                    //         //     btn : ['立即前往']
                    //         // }, function() {
                    //         //
                    //         // })
                    //     }
                    //     // else {
                    //     //         if (document.referrer != '') {
                    //     //             if (document.referrer.indexOf('forgetPass') != -1 || document.referrer.indexOf('registerWeb') != -1) {
                    //     //                 location.href = '/certificate/aboutMobile'
                    //     //             }
                    //     //         } else {
                    //     //             location.href = '/certificate/aboutMobile'
                    //     //         }
                    //     //     }
                    // }
                } else {
                    layer.msg(r.msg);
                }
            }
        });
    }

</script>
</body>





